<style lang="less" scoped>
  .f-w100 {
    width: 100%;
  }
</style>
<template>
  <div class="short-barge">
    <el-tabs v-model="activeName" @tab-click="handleClick" style="height: 100%">
      <el-tab-pane label="待中转" name="awaitTransit" style="height: 100%">
        <ue-search-bar ref="ueSearchBar" v-model="searchForm" :data="querysAwaitTransit" label-width="120px">
        </ue-search-bar>
        <el-col :span="24" style="margin-bottom: 10px">
          <el-col :span="5">
            <el-button type="primary" @click="assignCarrierDialogClick">指派承运商</el-button>
            <el-button type="primary" @click="changeAutomaticClick">外包改自送</el-button>
          </el-col>
          <el-col :span="11">
            <span style="font-size: 14px;margin-left: 50px;" v-html="jztHtml">当前选中：0 票 / 0 件 / 0 吨 / 0 方</span>
          </el-col>
          <el-col :span="8" style="text-align: right">
            <el-button>导出</el-button>
            <el-button type="primary" @click="awaitTransitQuery">查询</el-button>
            <el-button type="primary" @click="$refs.ueSearchBar.reset()">重置</el-button>
          </el-col>
        </el-col>
        <ue-el-table ref="orderTable" :data="transitEpibolyTableData" highlight-current-row border
                     @selection-change="selectChange"
                     @select="transitEpibolySelect"
                     style="height: 100%">
          <el-table-column fixed type="selection" width="55">
          </el-table-column>
          <ue-el-table-tree-column fixed
                                   :remote="remoteTransitEpiboly"
                                   prop="label"
                                   label="订单号"
                                   child-num-key="num"
                                   width="230">
          </ue-el-table-tree-column>
          <el-table-column show-overflow-tooltip prop="order.orderNumber" label="订单号" width="180">
          </el-table-column>
          <el-table-column label="等通知放货" width="120" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.order"> {{scope.row.order.noticeDeliveryStatus === 101022001?'否':(scope.row.order.noticeDeliveryStatus === 101022002? '是':scope.row.order.noticeDeliveryStatusName)}}</span>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.agingName" label="运输方式" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.sendTypeName" label="配送方式" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.cargoNames" label="货物品名" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.packTypeNames" label="包装" width="200">
            <template slot-scope="scope">
              <label
                v-if="scope.row.order !=null&&scope.row.order.packTypeNames !='null'">{{scope.row.order.packTypeNames}}
              </label>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="amountAndWeightAndVolume" label="件数/重量/体积" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.isReceipt" label="回单份数" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.collectionMoney" label="代收货款" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.orderPrice" label="到付" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order" label="收货人/电话" width="200">
            <template slot-scope="scope">
              <label
                v-if="scope.row.order !=null">{{scope.row.order.sendContactName}}<br>{{scope.row.order.sendContactPhone}}
              </label>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order" label="收货地址" width="200">
            <template slot-scope="scope">
              <label
                v-if="scope.row.order !=null">{{scope.row.order.sendTown}}<br>{{scope.row.order.sendStreet}}
              </label>
            </template>
          </el-table-column>
          <el-table-column fixed="right" show-overflow-tooltip prop="" label="备注" width="200">
          </el-table-column>
        </ue-el-table>
      </el-tab-pane>
      <el-tab-pane label="中转中" name="thisTransit" style="height: 100%">
        <ue-search-bar ref="thisTransitSearchForm" v-model="thisTransitSearchForm" :data="querysThisTransit"
                       label-width="120px">
        </ue-search-bar>
        <el-col :span="24" style="margin-bottom: 10px">
          <el-col :span="6">
            <el-button type="primary" @click="cancelClick">取消指派</el-button>
            <el-button @click="acceptClick">接受</el-button>
            <el-button @click="rejectClike">拒绝</el-button>
          </el-col>
          <el-col :span="18" style="text-align: right">
            <el-button>导出</el-button>
            <el-button type="primary" @click="thisTransitQuery">查询</el-button>
            <el-button type="primary" @click="$refs.thisTransitSearchForm.reset()">重置</el-button>
          </el-col>
        </el-col>
        <ue-el-table ref="thisEpibolyTableData" :data="thisEpibolyTableData" highlight-current-row border
                     @selection-change="selsThisChange"
                     style="height: 100%">
          <el-table-column fixed type="selection" width="55">
          </el-table-column>
          <ue-el-table-tree-column fixed
                                   :remote="remoteThisTransitEpiboly"
                                   prop="label"
                                   label="发运日期"
                                   child-num-key="num"
                                   width="230">
          </ue-el-table-tree-column>
          <el-table-column show-overflow-tooltip prop="order.orderNumber" label="订单号" width="180">
          </el-table-column>
          <el-table-column label="等通知放货" width="120" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.order"> {{scope.row.order.noticeDeliveryStatus === 101022001?'否':(scope.row.order.noticeDeliveryStatus === 101022002? '是':scope.row.order.noticeDeliveryStatusName)}}</span>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.orderStatusName" label="订单状态" width="180">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="isAccept" label="接受状态" width="180">
            <template slot-scope="scope">
              <label v-if="scope.row.isAccept===111002002">
                未接受
              </label>
              <label v-if="scope.row.isAccept===111002001">
                已接受
              </label>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip label="承运商负责人/电话" width="180">
            <template slot-scope="scope">
              {{scope.row.principal}}<br>{{scope.row.phone}}
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="transhipmentCharges" label="中转费" width="180">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="date" label="预计到达时间" width="180">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.agingName" label="运输方式" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.sendTypeName" label="配送方式" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.cargoNames" label="货物品名" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.packTypeNames" label="包装" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="amountAndWeightAndVolume" label="件数/重量/体积" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="isReceipt" label="回单分数" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="collectionMoney" label="代收货款" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order.orderPrice" label="到付" width="200">
            <template slot-scope="scope">
              <label
                v-if="scope.row.order !=null&&scope.row.order.paymentType===102002001">{{scope.row.order.orderPrice}}
              </label>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order" label="收货人/电话" width="200">
            <template slot-scope="scope">
              <label
                v-if="scope.row.order !=null">{{scope.row.order.sendContactName}}{{scope.row.order.sendContactPhone}}
              </label>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="order" label="收货地址" width="200">
            <template slot-scope="scope">
              <label
                v-if="scope.row.order !=null">{{scope.row.order.sendTown}}<br>{{scope.row.order.sendStreet}}
              </label>
            </template>
          </el-table-column>
          <el-table-column fixed="right" show-overflow-tooltip label="备注" width="200">
          </el-table-column>
        </ue-el-table>
      </el-tab-pane>
      <el-tab-pane label="历史中转" name="historyTransit">
        <ue-search-bar ref="historyTransitSearchForm" v-model="historyTransitSearchForm" :data="queryshistoryTransit"
                       label-width="120px">
        </ue-search-bar>
        <el-col :span="24" style="margin-bottom: 10px">
          <el-button>导出</el-button>
          <el-button type="primary" @click="$refs.historyTransitSearchForm.reset()">重置</el-button>
          <el-button type="primary" @click="historyEpibolyQuery">查询</el-button>
        </el-col>
        <ue-el-table ref="historyEpibolyTableData" :data="historyEpibolyTableData" highlight-current-row border
                     style="height: 100%">
          <ue-el-table-tree-column fixed
                                   :remote="remoteHistoryTransitEpiboly"
                                   prop="label"
                                   label="发运日期"
                                   child-num-key="num"
                                   width="230">
          </ue-el-table-tree-column>
          <el-table-column show-overflow-tooltip prop="transitEpiboly.order.orderNumber" label="订单号" width="180">
          </el-table-column>
          <el-table-column label="等通知放货" width="120" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.transitEpiboly"> {{scope.row.transitEpiboly.order.noticeDeliveryStatus === 101022001?'否':(scope.row.transitEpiboly.order.noticeDeliveryStatus === 101022002? '是':scope.row.transitEpiboly.order.noticeDeliveryStatusName)}}</span>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="transitEpiboly.order.orderStatusName" label="订单状态" width="180">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="acceptDate" label="签收日期" width="180">
          </el-table-column>
          <el-table-column show-overflow-tooltip label="承运商负责人/电话" width="180">
            <template slot-scope="scope">
              <label
                v-if="scope.row.transitEpiboly !=null">
                {{scope.row.transitEpiboly.principal}}<br>{{scope.row.transitEpiboly.phone}}
              </label>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip label="中转费" width="180">
            <template slot-scope="scope">
              <label
                v-if="scope.row.transitEpiboly !=null">
                {{scope.row.transitEpiboly.transhipmentCharges}}
              </label>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip label="预计到达时间" width="180">
            <template slot-scope="scope">
              <label
                v-if="scope.row.transitEpiboly !=null">
                {{scope.row.transitEpiboly.date}}
              </label>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="transitEpiboly.order.agingName" label="运输方式" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="transitEpiboly.order.sendTypeName" label="配送方式/要求到达时间"
                           width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="transitEpiboly.order.cargoNames" label="货物品名" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="transitEpiboly.order.packTypeNames" label="包装" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="transitEpiboly.amountAndWeightAndVolume" label="件数/重量/体积"
                           width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="transitEpiboly.order.isReceipt" label="回单份数" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="transitEpiboly.order.collectionMoney" label="代收货款" width="200">
          </el-table-column>
          <el-table-column show-overflow-tooltip label="到付" width="200">
            <template slot-scope="scope">
              <label
                v-if="scope.row.transitEpiboly !=null&&scope.row.transitEpiboly.order.paymentType===102002001">{{scope.row.transitEpiboly.order.orderPrice}}
              </label>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip label="收货人/电话" width="200">
            <template slot-scope="scope">
              <label
                v-if="scope.row.transitEpiboly !=null">{{scope.row.transitEpiboly.order.sendContactName}}<br>{{scope.row.transitEpiboly.order.sendContactPhone}}
              </label>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip prop="transitEpiboly.order" label="收货地址" width="200">
            <template slot-scope="scope">
              <label
                v-if="scope.row.transitEpiboly !=null && scope.row.transitEpiboly.order !=null">{{scope.row.transitEpiboly.order.sendTown}}<br>{{scope.row.transitEpiboly.order.sendStreet}}
              </label>
            </template>
          </el-table-column>
          <el-table-column fixed="right" show-overflow-tooltip label="备注" width="200">
          </el-table-column>
        </ue-el-table>
      </el-tab-pane>
    </el-tabs>
    <!--指派承运商Dialog-->
    <el-dialog title="指派承运商" :visible.sync="assignCarrierDialog" size="tiny">
      <el-form :model="assignCarrierForm" ref="assignCarrierForm" label-width="110px" style="width: 100%">
        <el-form-item label="承运商">
          <el-radio-group v-model="carrier" @change="carrierChange">
            <el-radio label="1">选择现有承运商</el-radio>
            <el-radio label="2">手工填写承运商</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="" prop="serviceProviderId" v-if="carrierBo">
          <el-select class="f-w100" @change="assignCarrierChange" v-model="assignCarrierForm.serviceProviderId"
                     placeholder="请选择承运商">
            <el-option
              v-for="item in serviceProvider"
              :key="item.value"
              :label="item.commonCarrierName"
              :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="serviceProviderName"
                      :rules="{ max: 100, message: '长度在 0 到 100 个字符', trigger: 'blur' }"
                      v-if="!carrierBo">
          <el-input v-model="assignCarrierForm.serviceProviderName"
                    placeholder="请填写承运商"></el-input>
        </el-form-item>
        <el-form-item label="负责人"
                      :rules="{ max: 20, message: '长度在 0 到 20 个字符', trigger: 'blur' }"
                      prop="principal">
          <el-input v-model="assignCarrierForm.principal" placeholder="请填写负责人"></el-input>
        </el-form-item>
        <el-form-item label="联系电话"
                      :rules="[
                        { type:'string', pattern:/^\d{11}$/, message: '请输入11位手机号码', trigger: 'blur,change' }
                      ]"
                      prop="phone">
          <el-input v-model="assignCarrierForm.phone" placeholder="请填写联系电话"></el-input>
        </el-form-item>
        <el-form-item label="中转车牌号"
                      :rules="{ max: 10, message: '长度在 0 到 10 个字符', trigger: 'blur' }"
                      prop="plateNumber">
          <el-input v-model="assignCarrierForm.plateNumber" placeholder="请填写中转车牌号"></el-input>
        </el-form-item>
        <el-form-item label="中转费"
                      :rules="[
                        { type: 'number', message: '请输入数字', trigger: 'blur,change' }
                        ]"
                      prop="transhipmentCharges">
          <el-input v-model.number="assignCarrierForm.transhipmentCharges"
                    placeholder="请填写中转费商"></el-input>
        </el-form-item>
        <el-form-item label="预计送达时间" prop="date"
                      :rules="{required: true,type: 'date', message: '请填写预计送达时间商', trigger: 'change'}">
          <el-date-picker class="f-w100" v-model="assignCarrierForm.date" type="datetime"
                          placeholder="请填写预计送达时间商"></el-date-picker>
        </el-form-item>
        <el-form-item label="备注">
          <el-input type="textarea" v-model="assignCarrierForm.remark" placeholder="备注"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="assignCarrierDialog = false">取 消</el-button>
        <el-button type="primary" @click="assignCarrierSave">确 定</el-button>
      </div>
    </el-dialog>

    <!--拒绝Dialog-->
    <el-dialog title="拒绝" :visible.sync="rejectDialog" size="tiny">
      <el-form label-width="110px" style="width: 400px">
        <el-form-item label="拒绝理由" :rules=" { required: true, message: '请填写拒绝理由', trigger: 'change' }">
          <el-input type="textarea" v-model="rejectMsg" placeholder="请填写拒绝理由"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="rejectDialog = false">取 消</el-button>
        <el-button type="primary" @click="rejectSave">确 定</el-button>
      </div>
    </el-dialog>

  </div>
</template>
<script>
import { searchServiceProviderByAddress } from '../../api/cap/serviceprovider.js';
import { isEmpty } from '../../lib/util.js';
import {
  saveTransitEpibolys,
  thisTransferGroup,
  searchThisTransferDetail, searchHistoryTransferDetail, trunkTasksPage,
  saveTransitEpibolysLog, saveTransitEpibolysRejectLog, deleteThisTransferDetail, shipmentsRegionAndNum
} from '../../api/transit/transitEpiboly.js';

export default {
  data () {
    return {
      carrierBo: true,
      selectDatas: [],
      selectThisDatas: [],
      assignCarriers: [],
      thisEpibolyTableData: [],
      historyEpibolyTableData: [],
      carrier: '1',
      assignCarrierDialog: false,
      rejectDialog: false,
      rejectMsg: '',
      searchForm: {},
      thisTransitSearchForm: {},
      historyTransitSearchForm: {},
      fs: '',
      thisFs: '',
      hisFs: '',
      hisFsv2: '',
      jztHtml: '',
      assignCarrierForm: {
        plateNumber: null,
        serviceProviderId: null,
        serviceProviderName: null,
        principal: null,
        phone: null,
        date: null,
        transhipmentCharges: null,
        remark: null,
        typeIds: []
      },
      transitEpibolyTableData: [],
      serviceProvider: [],
      activeName: 'awaitTransit'
    };
  },
  methods: {
    historyEpibolyQuery () {
      let fm = {};
      let iuy = this.historyTransitSearchForm;
      for (let sf in iuy) {
        fm[sf.replace('_', '_transitEpiboly.')] = iuy[sf];
        if (sf === 'GT_order.signOff.signOffDate' && !isEmpty(iuy[sf])) {
          iuy[sf.replace('GT_', 'GTE_')] = iuy[sf].substr(0, 10);
          delete iuy[sf];
        }
        if (sf === 'LT_order.signOff.signOffDate' && !isEmpty(iuy[sf])) {
          iuy[sf.replace('LT_', 'LTE_')] = iuy[sf].substr(0, 10);
          delete iuy[sf];
        }
      }
      this.hisFs = this.$ue.objToFilter(this.iuy);
      this.hisFsv2 = this.$ue.objToFilter(fm);
      this.handleClick({name: 'historyTransit'});
    },
    thisTransitQuery () {
      this.thisFs = this.$ue.objToFilter(this.thisTransitSearchForm);
      this.handleClick({name: 'thisTransit'});
    },
    awaitTransitQuery () {
      this.fs = this.$ue.objToFilter(this.searchForm);
      this.shortTasksShipmentsRegionAndNum(this.fs);
    },
    assignCarrierChange (val) {
      let models = this.$ue.getSelectObect(val, 'id', this.serviceProvider);
      this.assignCarrierForm.principal = models.principal;
      this.assignCarrierForm.phone = models.phone;
    },
    transitEpibolySelect (sel, row) {
      this.parentSelect('orderTable', sel, row);
    },
    parentSelect (ref, sel, row) {
      let ids = sel.map(i => i.id);
      if (sel.indexOf(row) > -1) {
        if (row.children) {
          row.children.forEach(item => {
            if (ids.indexOf(item.id) === -1) {
              this.$refs[ref].toggleRowSelection(item);
            }
          });
        } else {
          let children = sel.filter(item => {
            return item.parent_id === row.parent_id;
          });
          let parents = this.$refs[ref].store.states.data.filter(item => {
            return item.id === row.parent_id;
          });
          if (parents.length > 0 && parents[0].children.length === children.length) {
            this.$refs[ref].toggleRowSelection(parents[0]);
          }
        }
      } else {
        if (row.children) {
          row.children.forEach(item => {
            if (ids.indexOf(item.id) > -1) {
              this.$refs[ref].toggleRowSelection(item, false);
            }
          });
        } else {
          let parents = sel.filter(item => {
            return item.id === row.parent_id;
          });
          if (parents.length > 0) {
            this.$refs[ref].toggleRowSelection(parents[0], false);
          }
        }
      }
    },
    shortTasksShipmentsRegionAndNum (filters) {
      filters = isEmpty(filters) ? 'EQ_nextOrganizationExecuteTypeId=112012001;EQ_isTransitEpiboly=111002002' : 'EQ_nextOrganizationExecuteTypeId=112012001;EQ_isTransitEpiboly=111002002;' + filters;
      shipmentsRegionAndNum({filters: filters}).then(res => {
        this.transitEpibolyTableData = res.data.detailModelList;
        this.transitEpibolyTableData.forEach(item => {
          item.type = 'group';
        });
      });
    },
    changeAutomaticClick () {
      if (this.$ue.isEmpty(this.selectDatas)) {
        return this.$message.error('请选择数据');
      }
    },
    assignCarrierSave () {
      if (this.carrier === '1') {
        this.assignCarrierForm.serviceProviderName = this.$ue.getSelectObect(this.assignCarrierForm.serviceProviderId, 'id', this.serviceProvider).commonCarrierName;
      } else {
        this.assignCarrierForm.serviceProviderId = '';
      }
      let typeIds = [];
      this.selectDatas.forEach(item => {
        typeIds.push({
          id: item.id,
          type: item.type === 'group' ? 'send_group' : ''
        });
      });
      let o = Object.assign({}, this.assignCarrierForm);
      o.typeIds = typeIds;
      this.$refs['assignCarrierForm'].validate((assignCarrierFormValid) => {
        if (assignCarrierFormValid) {
          o.date = o.date.toJSON();
          saveTransitEpibolys(o).then(res => {
            if (res.data.successFlg) {
              this.shortTasksShipmentsRegionAndNum();
              this.$message.success('指派成功');
              this.assignCarrierDialog = false;
            }
          });
        }
      });
    },
    carrierChange (val) {
      if (val === '1') {
        this.carrierBo = true;
      } else {
        this.assignCarrierForm.serviceProviderName = '';
        this.carrierBo = false;
      }
    },
    assignCarrierDialogClick () {
      if (this.$ue.isEmpty(this.selectDatas)) {
        return this.$message.error('请先选择要指派的数据');
      }
      this.assignCarrierDialog = true;
      if (this.$refs.assignCarrierForm) {
        this.$refs.assignCarrierForm.resetFields();
      }
      for (let p in this.assignCarrierForm) {
        if (this.assignCarrierForm[p] instanceof Array) {
          this.assignCarrierForm[p] = [];
        } else {
          this.assignCarrierForm[p] = null;
        }
      }
      const [first] = this.selectDatas;
      const {sendProvinceId, sendCityId, sendCountyId} = first.order;
      let filters = 'EQ_status=111002001';
      this.searchServiceProvider(filters, sendProvinceId + ',' + sendCityId + ',' + sendCountyId);
    },
    searchServiceProvider (filters, addressArray) {
      searchServiceProviderByAddress({
        filters: filters,
        addresses: addressArray,
        size: 15,
        page: 1,
        sorts: '-createDate'
      }).then(res => {
        if (res.data.successFlg) {
          this.serviceProvider = res.data.detailModelList;
        }
      });
    },
    selectChange (sels) {
      this.selectDatas = sels;
      let j = 0;
      let z = 0;
      let t = 0;
      let totalNumbers = 0;
      sels.forEach(sl => {
        if (sl.order != null) {
          ++totalNumbers;
          j = j + sl.order.amount;
        }
        if (sl.order != null) {
          z = z + sl.order.volume;
        }
        if (sl.order != null) {
          t = t + sl.order.weight;
        }
      });
      this.jztHtml = '当前选中 : ' + totalNumbers + ' 票 / ' + j + '件 / ' + z + '吨 / ' + j + '方';
    },
    selsThisChange (sels) {
      this.selectThisDatas = sels;
    },
    remoteTransitEpiboly (row, callback) {
      let filters = isEmpty(this.fs) ? 'EQ_nextOrganizationExecuteTypeId=112012001;EQ_isTransitEpiboly=111002002;EQ_order.sendCountyId=' + row.sendCountyId : 'EQ_nextOrganizationExecuteTypeId=112012001;EQ_isTransitEpiboly=111002002;EQ_order.sendCountyId=' + row.sendCountyId + ';' + this.fs;
      trunkTasksPage({filters: filters}).then(res => {
        if (res.data.successFlg) {
          res.data.detailModelList.forEach(rs => {
            rs.label = rs.order.shipmentsDate.substring(0, 10);
            rs.parent_id = row.id;
          });
          callback(res.data.detailModelList);
        }
      });
    },
    remoteThisTransitEpiboly (row, callback) {
      let filters = 'EQ_isAccept=111002002;EQ_order.shipmentsCountyId=' + row.shipmentsCountyId + ';' + this.thisFs;
      searchThisTransferDetail({filters: filters}).then(res => {
        if (res.data.successFlg) {
          res.data.detailModelList.forEach(rs => {
            rs.label = rs.order.shipmentsDate.substring(0, 10);
            rs.parent_id = row.id;
          });
          callback(res.data.detailModelList);
        }
      });
    },
    remoteHistoryTransitEpiboly (row, callback) {
      searchHistoryTransferDetail({filters: 'EQ_status=111002001;EQ_transitEpiboly.order.shipmentsCountyId=' + row.shipmentsCountyId + ';' + this.hisFsv2}).then(res => {
        if (res.data.successFlg) {
          res.data.detailModelList.forEach(r => {
            r.label = r.transitEpiboly.order.shipmentsDate.substring(0, 10);
            r.parent_id = row.id;
          });
          callback(res.data.detailModelList);
        }
      });
    },
    handleClick (tab) {
      if (tab.name === 'awaitTransit') {
      } else if (tab.name === 'thisTransit') {
        thisTransferGroup({filters: 'EQ_isAccept=111002002;' + this.thisFs}).then(res => {
          if (res.data.successFlg) {
            this.thisEpibolyTableData = res.data.detailModelList;
            this.thisEpibolyTableData.forEach(item => {
              item.type = 'group';
            });
          }
        });
      } else if (tab.name === 'historyTransit') {
        thisTransferGroup({filters: 'EQ_transitEpibolyLogs.status=111002001;' + this.hisFs}).then(res => {
          if (res.data.successFlg) {
            this.historyEpibolyTableData = res.data.detailModelList;
          }
        });
      }
    },
    rejectSave () {
      this.rejectDialog = false;
      this.selectThisDatas.forEach(std => {
        std.remark = this.rejectMsg;
      });
      saveTransitEpibolysRejectLog(this.selectThisDatas).then(res => {
        if (res.data.successFlg) {
          this.handleClick({name: 'thisTransit'});
        }
      });
    },
    cancelClick () {
      if (this.$ue.isEmpty(this.selectThisDatas)) {
        return this.$message.error('请先选择数据');
      }
      this.$confirm('是否取消选中的中转任务?', '提示', {
        type: 'warning'
      }).then(() => {
        let typeIds = [];
        this.selectThisDatas.forEach(item => {
          typeIds.push({
            id: item.id,
            type: item.type === 'group' ? 'shipments_group' : ''
          });
        });
        deleteThisTransferDetail(typeIds).then(res => {
          this.$message.success('取消成功');
          this.shortTasksShipmentsRegionAndNum();
          this.handleClick({name: 'thisTransit'});
        });
      }).catch(() => {});
    },
    rejectClike () {
      if (this.$ue.isEmpty(this.selectThisDatas)) {
        return this.$message.error('请先选择数据');
      }
      this.rejectDialog = true;
    },
    acceptClick () {
      if (this.$ue.isEmpty(this.selectThisDatas)) {
        return this.$message.error('请先选择数据');
      }
      this.$confirm('是否接受选中的中转任务?', '提示', {
        type: 'warning'
      }).then(() => {
        saveTransitEpibolysLog(this.selectThisDatas).then(res => {
          this.$message.success('接受成功');
          this.handleClick({name: 'thisTransit'});
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    }
  },
  mounted () {
    this.shortTasksShipmentsRegionAndNum();
    this.$store.commit('initDict');
  },
  computed: {
    btns () {
      return this.$store.state.btns[this.$route.path] || [];
    },
    querysAwaitTransit () {
      return this.$store.state.querys[this.$route.path + '#await_transit'] || [];
    },
    querysThisTransit () {
      return this.$store.state.querys[this.$route.path + '#this_transit'] || [];
    },
    queryshistoryTransit () {
      return this.$store.state.querys[this.$route.path + '#history_transit'] || [];
    }
  }
};
</script>
